<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>单位名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="Name" value="{{.department.Name}}" required=""
                           lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red">*</span>单位编码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="phone" name="Code" required="" lay-verify="required"
                           value="{{.department.Code}}"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_email" class="layui-form-label">
                    <span class="x-red">*</span>排序
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="L_email" name="Sort" required="" lay-verify="number"
                           value="{{.department.Sort}}"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>上级单位</label>
                <div class="layui-input-block">
                    <select  name="Pid">
                        <option style='display: none'  value="0"></option>
                        {{$pid := .department.Pid}}
                        {{range $value := .list}}
                            <option lay-skin="primary" {{if compare $value.id $pid}} selected="selected" {{end}}
                                    class="layui-input" value="{{$value.id}}">{{$value.name}}</option>
                        {{end}}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    更新
                </button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(add)',
                function (data) {
                    console.log(data)
                    request_post("/admin/department/update/{{.department.Id}}", data.field).then(function (data) {
                        layer.alert("修改成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();

                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    }, function (error) {
                        msg_error(error.msg)
                    })
                    return false;
                });

        });</script>